package com.example.gridfsdemo.vo;

import com.mongodb.client.gridfs.model.GridFSFile;
import lombok.Data;
import org.bson.BsonValue;
import org.bson.Document;
import org.springframework.beans.BeanUtils;

import java.util.Date;

/**
 * @author susc
 * @title: GridFSFileVO
 * @projectName gridfs-demo
 * @description: TODO
 * @date 2022/8/2610:37
 */
@Data
public class GridFSFileVO {
    private String objectId;
    private  String filename;
    private  long length;
    private  int chunkSize;
    private  Date uploadDate;
    // Optional values
    private  Document metadata;

    public GridFSFileVO() {
    }

    public GridFSFileVO(GridFSFile gridFSFile) {
        if(null != gridFSFile){
            BeanUtils.copyProperties(gridFSFile, this);
            String objectId = gridFSFile.getObjectId().toString();
            setObjectId(objectId);
        }

    }
}
